package greendao.example;




import greendao.example.DaoMaster;
import greendao.example.DaoSession;
import greendao.example.DaoMaster.OpenHelper;
import android.app.Application;
import android.content.Context;

public class MyApplication extends Application  {
	
	private static Context mCurrentContext;
	
	
	private static DaoMaster daoMaster;  
    private static DaoSession daoSession;  
	
    private static MyApplication instance;
    
	public MyApplication() {
    }

    

    public static MyApplication getInstance() {
            return instance;
    }

    public static Context getCurrentContext() {
            return mCurrentContext;
    }
	
    
    public static DaoMaster getDaoMaster(Context context) {  
        if (daoMaster == null) {  
            OpenHelper helper = new DaoMaster.DevOpenHelper(context,"custom.db", null);  
            daoMaster = new DaoMaster(helper.getWritableDatabase());  
        }  
        return daoMaster;  
    }  
    
    
    public static DaoSession getDaoSession(Context context) {  
        if (daoSession == null) {  
            if (daoMaster == null) {  
                daoMaster = getDaoMaster(context);  
            }  
            daoSession = daoMaster.newSession();  
        }  
        return daoSession;  
    }  
    
	
}
